﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using RestAndPlay.Core.Model;

namespace RestAndPlay.Core.Repository
{
    public class PlaylistRepository
    {

        List<PlaylistSong> storage;

        public PlaylistRepository()
        {
            this.storage = new List<PlaylistSong>();
        }

        public void UpdateStatus(PlaylistSong song, PlaylistSongStatus status)
        {
            var selectedSong = this.storage.Single(s => s.Song.Path == song.Song.Path);
            selectedSong.Status = status;
        }

        public void Queue(PlaylistSong song)
        {
            this.storage.Add(song);
        }

        public void Dequeue(string path)
        {
            this.storage.Remove(this.storage.Where(s => s.Song.Path == path).Single());
        }

        public void Dequeue(PlaylistSong song)
        {
            this.storage.Remove(song);
        }

        public List<PlaylistSong> GetPlaylist()
        {
            return this.storage.ToList();
        }

    }
}
